package br.ufrgs.inf.sissw.app.interfaces;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import br.ufrgs.inf.sissw.app.R;
import br.ufrgs.inf.sissw.app.models.AgendaItem;


public class AgendaCustomArrayAdapter extends ArrayAdapter<AgendaItem> {

	private CheckBox itemStatus;
	private TextView itemTitle;
	
	private Context context;
	private List<AgendaItem> itemsList = new ArrayList<AgendaItem>();
	
	public AgendaCustomArrayAdapter(Context context, int textViewResourceId, List<AgendaItem> itemsList) {
		super(context, textViewResourceId, itemsList);
		this.context = context;
		this.itemsList = itemsList;
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View row = convertView;
		
		if (row == null) {
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			row = inflater.inflate(R.layout.agenda_row_layout, null);
		}

		
		AgendaItem item = itemsList.get(position);
		itemStatus = (CheckBox) row.findViewById(R.id.checkBoxItem);
		
		itemTitle = (TextView) row.findViewById(R.id.textViewItemTitle);
		item.setItemDescription("Apresentação sinistra");
		itemStatus.setChecked(item.isDone());
		itemTitle.setText(item.getItemTitle());
		item.setItemDate(new Date(2011, 04, 30, 21, 10));
		
		return row;
	}
}
